<template>
	<view>
		<bsNavBar title='培训课程'></bsNavBar>
		<worksList :props='props' onMsg='暂无培训课程' @handDetails='handDetails' :status='status' :list='findCourseList'></worksList>
	</view>
</template>

<script>
	import worksList from '@/components/bs-works-list/bs-works-list.vue'
	export default {
		components: {
			worksList
		},
		data() {
			return {
				status: 'nomore',
				paging: {
					page: 1,
					pageSize: 10,
				},
				props: {
					courseTitle: 'title',
					listImage: 'titleImg'
				},
				pages: 0,
				findCourseList: []
			};
		},
		async onLoad(e) {
			if (e.query) {
				this.paging.awardType = e.query
			}
			await this.init()
		},
		async onPullDownRefresh() {
			await this.init()
			uni.stopPullDownRefresh();
		},
		methods: {
			async handDetails(item) {
				uni.navigateTo({
					url: '/pages/onlineTrain/trainDetails/trainDetails?courseId=' + item.courseId
				})
			},
			async getMore() {
				if (this.pages == this.paging.page) {
					this.status = 'nomore';
					return
				}
				this.status = 'loading';
				this.paging.page = ++this.paging.page;
				let findCourseList = await this.$u.api.findCourseList({
					...this.paging,
				})
				this.pages = findCourseList.pages
				this.findCourseList = this.findCourseList.concat(findCourseList.list)
				this.status = 'loadmore';
			},
			async init() {
				this.paging.page = 1
				this.paging.type = 0
				this.status = 'loading'
				let findCourseList = await this.$u.api.findCourseList({
					...this.paging,
				})
				console.log(findCourseList, '作品申报')
				this.pages = findCourseList.pages
				this.findCourseList = findCourseList.list
				if (this.pages == this.paging.page) {
					this.status = 'nomore';
				}
			}
		}
	}
</script>

<style lang="scss">

</style>
